package yf.mall.entity;


import lombok.Setter;
import lombok.Getter;

import java.io.Serializable;
import java.util.Date;


/**
 * 活动实体
 * 表名 mall_act
 *
 * @author hxf
 * @email 505860922@qq.com
 * @date Fri Aug 28 15:23:50 CST 2020
 */
@Setter
@Getter
public class MallActEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    //
    private Long id;
    //活动名称
    private String name;
    //产品ID
    private Long goodsId;
    //绑定产品ID
    private Long bindGoodsId;
    //绑定数量
    private Integer bindGoodsQuantity;
    //活动触发数量
    private Integer quantity;
    //规格id
    private Integer skuId;
    //开始时间
    private Date start;
    //起止时间
    Date[] starts;
    //结束时间
    private Date end;
    //起止时间
    Date[] ends;
    //不可购买级别
    private String level;
    //限购数量
    private Integer number;
    //奖励
    private String reward;
    //活动库存
    private Integer stock;
    //ENUM-状态:"OPEN-打开","CLOSED-关闭"
    private Integer status;
    //绑定抽奖活动id
    private Long bindLotteryId;
    //捆绑主产品id
    private Integer firstGoodsQuantity;
    //活动方式
    private Integer mode;

    public MallActEntity() {

    }

    private String goodsName;
    private String shopName;

    public Boolean getOpen() {
        Date today = new Date();
        if (start == null || stock == null || status == null) return false;
        //打开状态  库存充足  时间范围内
        if (status == 0 && today.after(start) && today.before(end)) {
            return true;
        }
        return false;
    }
}
